/*******************************************************************************
* FileName:         MyString.cpp
* Author:           李智铭
* Student Number:   3022206093
* Date:             2024/10/30 17:00:00
* Version:          v1.0
* Description:      Data Structure Experiment #5
*******************************************************************************/
#ifndef MYSTRING_H
#define MYSTRING_H

class MyString {
private:
    char* str;
    int len;

    // 计算字符串长度
    static int strlen(const char* input) { // 设为 static
        int i = 0;
        while (input[i] != '\0') {
            i++;
        }
        return i;
    }

    // 复制字符串内容
    static void copystr(char* s, const char* ss, int length) { // 设为 static
        for (int i = 0; i < length; i++) {
            s[i] = ss[i];
        }
        s[length] = '\0';
    }

public:
    MyString(const char*);
    ~MyString();
    void showstr();
    void replace(const char* str, int location);
    int length() const;
    void buildLPSArray(const char*, int, int*)const;
    int find(const char*) const;
    const char* c_string() const;
};

#endif
